﻿using SymulatorEthernetWPF.SimObjects;
using SymulatorEthernetWPF.SimObjects.Layers.DataLink;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SymulatorEthernetWPF.UserInterface
{
    /// <summary>
    /// Interaction logic for ReceivedData.xaml
    /// </summary>
    public partial class ReceivedDataItem : UserControl
    {
        public ReceivedDataItem(ReceivedData received)
        {
            
            InitializeComponent();
            Time.Content = received.time;
            switch (received.frameAction)
            {
                case FrameAction.Collided:
                    State.Content = "Kolizja";
                    this.Background = Brushes.IndianRed;
                    break;
                case FrameAction.Received:
                    State.Content = "Odebrane";
                    this.Background = Brushes.LightGreen;
                    break;
                case FrameAction.Switched:
                    State.Content = "Przełączona";
                    this.Background = Brushes.Yellow;
                    break;
                case FrameAction.Rejected:
                    State.Content = "Odrzucona";
                    this.Background = Brushes.CornflowerBlue;
                    break;
                default:
                    State.Content = "?";
                    break;

            }
            try
            {

                SourceAdress.Content = received.data.source.ToString();
            }
            catch { }
            try
            {
                DestinationAdress.Content = received.data.destination.ToString();
            }
            catch { }
        }
    }
}
